import java.awt.event.ActionEvent;

import javax.swing.JButton;


public class ItemLoss extends RandomEvent {
	
	
	private JButton ok;
	private String message;
	Item.ItemType type;
	
	public ItemLoss(MainCardPanel display, Party p, String message, Item.ItemType t)
	{
		super(display, p);
		ok = new JButton("ok");
		ok.addActionListener(this);
		this.type = t;
		imageFilename = "item_loss.jpg";
		displayName = message;
	}

	@Override
	public void decay() {
		super.decay();
		dead = true;
		return;

	}
	
	public void actionPerformed(ActionEvent e)
	{
		super.actionPerformed(e);
		Item victim = null;
		for (Item i:p.getInventory())
			if (i.getType()==type)
			{
				victim = i;
				break;
			}
		if (victim!=null)
			p.getInventory().remove(victim);
	}

	@Override
	public JButton[] getResponseElements() {
		JButton[] ret = {ok};
		return ret;
	}

}
